<template>
  <div class="userZone">
    <!-- 头部导航 -->
    <div>
      <van-nav-bar
        left-text=""
        left-arrow
        class="navbar"
        :title="currentArt.aut_name"
        @click-left="$router.back()"
      >
        <template #right>
          <van-icon name="ellipsis" size="18" />
        </template>
      </van-nav-bar>
    </div>
    <!-- 用户信息区域 -->
    <div class="userInfo">
      <div class="left">
        <img :src="currentArt.aut_photo" alt="" />
      </div>
      <div class="right">
        <div>
          <div class="up">64451</div>
          <div class="down">发布</div>
        </div>
        <div>
          <div class="up">{{ currentArt.attitude }}</div>
          <div class="down">关注</div>
        </div>
        <div>
          <div class="up">520</div>
          <div class="down">粉丝</div>
        </div>
        <div>
          <div class="up">772</div>
          <div class="down">获赞</div>
        </div>
      </div>
      <div class="focusOn">
        <div
          class="btn follow"
          v-if="getMyprop(currentArt.aut_id)"
          @click="cancelfollow"
        >
          <span class="btn-text">已关注</span>
        </div>
        <div class="btn" v-else @click="follow">
          <span class="add">+</span>
          <span class="btn-text">关注</span>
        </div>
      </div>
    </div>

    <!-- 用户认证 -->
    <div class="userCertification">
      <div class="up"><em>认证:</em></div>
      <div class="down"><em>简介</em>:神思者111</div>
    </div>
    <!-- 用户发表文章 -->
    <div class="userPublicArticle">
      <div class="cellArticle" v-for="(item, index) in 20" :key="index">
        <div class="up">
          <div class="left">
            <img :src="currentArt.aut_photo" alt="" />
          </div>
          <div class="right">
            <div class="r-up">{{ currentArt.aut_name }}</div>
            <!-- 时间转换 -->
            <div class="r-down" ref="">
              {{ currentArt.pubdate | mydayjstime }}
            </div>
          </div>
        </div>
        <div class="middle">
          <div class="word" @click="$router.back()">
            哈哈哈哈哈哈哈
          </div>
          <div class="btn">
            <button>{{ currentArt.aut_name }}</button>
            <button>{{ currentArt.ch_id }}评论</button>
            <button>刚刚</button>
          </div>
        </div>
        <div class="down">
          <div @click="$router.back()">
            <van-icon name="comment-o" class="icon" />1122
          </div>
          <div @click="$router.back()" class="haveBorder">
            <van-icon name="like-o" class="icon" />59
          </div>
          <div><van-icon name="share-o" class="icon" />分享</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapGetters, mapActions } from 'vuex'
import { attention, Cancelattention } from '../../../api/user.js'
// 导入时间插件
export default {
  computed: {
    ...mapState(['currentArt', 'followList']),
    ...mapGetters(['getMyprop'])
  },
  methods: {
    ...mapActions(['setFlIdList']),
    async follow () {
      this.$toast({
        type: 'loading',
        message: '加载中',
        duration: 0
      })
      const res = await attention({ target: this.currentArt.aut_id })
      this.setFlIdList()
      this.$toast.success('关注成功')
      console.log(res)
    },
    async cancelfollow () {
      this.$toast({
        type: 'loading',
        message: '加载中',
        duration: 0
      })
      const res = await Cancelattention(this.currentArt.aut_id)
      this.setFlIdList()
      this.$toast.success('取消关注成功')
      console.log(res)
    }
  }
}
</script>

<style lang="less" scoped>
.userZone {
  background-color: rgb(245, 247, 249);
  .navbar {
    background-color: rgb(62, 157, 248);
    // color: #fff;
    /deep/ .van-icon-arrow-left::before {
      color: #fff;
    }
    /deep/ .van-icon-ellipsis::before {
      color: #fff;
    }
    /deep/ .van-nav-bar__title {
      color: #fff;
    }
  }
  .userInfo {
    background-color: #fff;
    padding-top: 50px;
    width: 100%;
    height: 200px;
    .left {
      img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        float: left;
        margin: 0 20px;
      }
    }
    .right {
      display: flex;
      div {
        flex: 1;
        // width: 20%;
        height: 36px;
        font-size: 20px;

        .up {
          display: block;
          font-size: 20px;
          text-align: center;
        }
        .down {
          display: block;
          font-size: 16px;
          color: rgb(141, 140, 140);
          text-align: center;
        }
      }
    }
    .focusOn {
      margin: 50px 90px 0 150px;
      .follow.btn {
        background-color: rgb(237, 237, 237);
        line-height: 20px;
        color: #333;
      }
      .btn {
        background-color: #3296fa;
        padding: 0px 30px;
        height: 30px;
        color: #fff;
        border-radius: 8px;
        margin-right: 20px;
        .add {
          font-size: 20px;
          line-height: 26px;
          margin-right: 5px;
        }
        .btn-text {
          font-size: 14px;
          line-height: 22px;
        }
      }
    }
  }
  /deep/ .userInfo .right div .up[data-v-8fea3240] {
    font-size: 24px;
  }
  .userCertification {
    background-color: #fff;
    margin-top: 10px;
    height: 100px;
    .up,
    .down {
      padding: 10px 0 10px 10px;
      font-size: 18px;
      color: rgb(44, 43, 43);
    }
  }
  .userPublicArticle {
    background-color: #fff;
    margin-top: 10px;
    height: 500px;
    .cellArticle {
      margin-top: 10px;
      .up {
        padding-top: 20px;
        padding-bottom: 20px;
        .left {
          img {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            float: left;
            margin: 10px 10px;
          }
        }
        .right {
          .r-up {
            font-size: 18px;
            padding-top: 10px;
            color: rgb(77, 75, 75);
          }
          .r-down {
            font-size: 18px;
            padding-top: 10px;
            color: rgb(170, 168, 168);
          }
        }
      }
      .middle {
        .word {
          padding-left: 10px;
          font-size: 18px;
        }
        .btn {
          margin-top: 8px;
          button {
            margin: 10px;
            border: none;
            background-color: #fff;
            color: rgb(156, 155, 155);
            font-size: 14px;
          }
        }
      }
      .down {
        height: 50px;
        display: flex;
        border-top: 1px solid rgb(245, 247, 249);
        border-bottom: 1px solid rgb(245, 247, 249);
        margin-top: 10px;
        div {
          // padding-top: 10px;
          flex: 1;
          font-size: 16px;
          line-height: 50px;
          text-align: center;
          color: rgb(51, 51, 51);
          .icon {
            margin: 10px;
            padding-top: 5px;
            font-size: 20px;
          }
        }
        .haveBorder {
          border-left: 1px solid rgb(245, 247, 249);
          border-right: 1px solid rgb(245, 247, 249);
        }
      }
    }
  }
}
</style>
